#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""

@author ：chenzf
@date ：2024/4/23 下午1:48 
"""
import array
import json
from datetime import datetime
from decimal import Decimal


class MyEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, datetime):
            print("MyEncoder-datetime.datetime")
            return obj.strftime("%Y-%m-%d %H:%M:%S")
        if isinstance(obj, bytes):
            return str(obj, encoding='utf-8')
        if isinstance(obj, int):
            return int(obj)
        elif isinstance(obj, float):
            return float(obj)
        elif isinstance(obj, array.ArrayType):
           return obj.tolist()
        elif isinstance(obj,Decimal):
            return obj.__float__()
        else:
            return super(MyEncoder, self).default(obj)